﻿/* Filename: Graphics.as 
 *
 * Description: This class is used to create
 * and draw objects on the screen.  It creates
 * two empty movie clips, one inside the other.
 * The inner one is replaced with the loaded object
 * so the outter object can still be used in code.
 *
 * Tyler Samson
 * Feb 2008
 * @ Sierra Nevada College
 */
 class Graphics {
	 
		
	private static var _menuTextFormat:TextFormat = 
		new TextFormat("Impact", 30, 0xCCCCCC, false, false, false, null, null, "center");
	
	public static function loadAndDrawObject(p_objectName:String, p_objectDepth:Number,
									  p_objectStoredGraphicName:String,
									  p_xLocation:Number, p_yLocation:Number) {
		
		/*trace("object: " + p_objectName + " depth: " + p_objectDepth +
			  "\ngraphicName: " + p_objectStoredGraphicName +
			  "\nx: " + p_xLocation + " y: " + p_yLocation);*/
		
		_root.createEmptyMovieClip(p_objectName, p_objectDepth);						// create an empty movie clip onscreen to load to
		_root[p_objectName].createEmptyMovieClip(p_objectName + "I", 1);				// create an empty movie clip inside the first (depth is 1 within the outter clip)
		_root[p_objectName][p_objectName + "I"].loadMovie(p_objectStoredGraphicName);	// load object to inner empty movie clip
		_root[p_objectName]._y = p_yLocation;											// move object to correct vertical location
		_root[p_objectName]._x = p_xLocation;											// move object to correct horizontal location		
	}
	
	public static function menuButton(p_name:String, p_depth:Number, p_x:Number, p_y:Number, p_isValid:Boolean) {
		if (p_isValid) {
			loadAndDrawObject(p_name, p_depth, "menus/menuButton1.png", p_x, p_y);	// create an empty movie clip onscreen to load to
			//loadAndDrawObject("Menu" + p_y, p_depth, "menus/menuButton1.png", p_x, p_y);	// create an empty movie clip onscreen to load to
		} else {
			loadAndDrawObject(p_name, p_depth, "menus/menuButton3.png", p_x, p_y);	// create an empty movie clip onscreen to load to
			//loadAndDrawObject("Menu" + p_y, p_depth, "menus/menuButton3.png", p_x, p_y);	// create an empty movie clip onscreen to load to
		}
		
		_root[p_name].createTextField("Text", 8, 30, 4, 200, 100);				// create text field on button
		//createTextField(instanceName:String, depth:Number, x:Number, y:Number, width:Number, height:Number)
		_root[p_name].Text.text = p_name;										// set the actual text on the button
		_root[p_name].Text.selectable = false;									// make the text static text, not dynamic
		
		_root[p_name].Text.setTextFormat(_menuTextFormat);
		
		/*_root["attack"].onPress = function () {
			_root["attack"]["attackText"].text = "PRESSED!";
		}
		
		_root["attack"].onRelease = function () {
			_root["attack"]["attackText"].text = "RELEASED!";
		}
		
		_root["attack"].onRollOver = function () {
			_root["attack"]["attackText"].text = "ROLLED!";
		}*/
	}
}